SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [ssb].[tsmTST] (@inpTbl AS SSB.ssbIncomeType READONLY)
AS 
BEGIN
SET NOCOUNT ON ;
--SET XACT_ABORT ON ;

 --DECLARE @errLog TABLE (Fund VARCHAR(MAX), accName VARCHAR(MAX), lcc VARCHAR(max), periodEndDate DATE )
 --DECLARE @sc TABLE(Change VARCHAR(20));
 --MERGE INTO dbo.SSBDailyIncome AS t
-- USING @p AS src
-- ON t.AccountName =src.AccountName 
-- AND t.Fund = src.Fund
-- AND t.LocalCurrencyCode = src.LocalCurrencyCode
-- AND t.PeriodEndDate = src.PeriodEndDate

-- --WHEN MATCHED THEN
--	--INSERT @errLog
--	--        ( Fund, accName, lcc, periodEndDate )
--	--VALUES  ( src.fund, src.accountName, src.LocalCurrencyCode, src.PeriodEndDate)
--WHEN NOT MATCHED by target THEN 
--	           INSERT 
--         ( Fund
--         , FundName
--         , AccountNumber
--         , SubAccountNumber
--         , AccountName
--         , Basis
--         , ReportDateStartingBalance
--         , ReportDateCredits
--         , ReportDateDebits
--         , ReportDateNetAmount
--         , EndingLedgerBalance
--         , EndingLedgerBalanceDBCRInd
--         , FinancialCurrencyName
--         , FinancialStatementCurrency
--         , LocalCurrencyCode
--         , LocalCurrencyName
--         , BaseCurrencyCode
--         , BaseCurrencyName
--         , MultiCurrencyFlag
--         , PeriodEndDate
--         , PeriodStartDate
--         , PostingPeriod
--         , RealMemoIndicator

--         )
--		 VALUES(           src.Fund
--         , src.FundName
--         , src.AccountNumber
--         , src.SubAccountNumber
--         , src.AccountName
--         , src.Basis
--         , src.ReportDateStartingBalance
--         , src.ReportDateCredits
--         , src.ReportDateDebits
--         , src.ReportDateNetAmount
--         , src.EndingLedgerBalance
--         , src.EndingLedgerBalanceDBCRInd
--         , src.FinancialCurrencyName
--         , src.FinancialStatementCurrency
--         , src.LocalCurrencyCode
--         , src.LocalCurrencyName
--         , src.BaseCurrencyCode
--         , src.BaseCurrencyName
--         , src.MultiCurrencyFlag
--         , src.PeriodEndDate
--         , src.PeriodStartDate
--         , src.PostingPeriod
--         , src.RealMemoIndicator)
--		  WHEN MATCHED 
--		    THEN DELETE 
--		OUTPUT $ACTION INTO @sc;
--		SELECT * FROM  @sc 

INSERT INTO SSB.DailyIncome_Dump
       
       
		 SELECT * FROM  @inpTbl	


END 


--		 TRUNCATE TABLE dbo.SSBDailyIncome
-- SELECT * FROM  dbo.SSBDailyIncome
GO
EXEC sp_addextendedproperty N'VirtualFolder', N'SSB', 'SCHEMA', N'SSB', 'PROCEDURE', N'tsmTST', NULL, NULL
GO
